﻿using System;
using System.Collections.Generic;
using System.Drawing;
using RaytracerLib.Cameras;
using RaytracerLib.MathLib;
using YAXLib;

namespace RaytracerLib.Samplers
{
    public abstract class Sampler
    {
        internal Film Film;

        public static Sampler Create(SamplerType a_type)
        {
            if (a_type == SamplerType.Grid)
                return new GridSampler();
            else if (a_type == SamplerType.Jitter)
                return new JitterSampler();
            else if (a_type == SamplerType.Poisson)
                return new PoissonSampler();
            else if (a_type == SamplerType.Halton)
                return new HaltonSampler();
            else if (a_type == SamplerType.Hammersley)
                return new HammersleySampler();
            else if (a_type == SamplerType.HaltonFolded)
                return new HaltonFoldedSampler();
            else if (a_type == SamplerType.HammersleyFolded)
                return new HammersleyFoldedSampler();
            else if (a_type == SamplerType.Sobol)
                return new SobolSampler();
            else
                throw new InvalidOperationException();
        }

        internal virtual void RenderStart(RenderStartPhase a_phase)
        {
        }

        public abstract IEnumerable<Vector2> GetSamples(Rectangle a_rect);
        public abstract SamplerType SamplerType { get; }
    }
}